Embodiments relate to accessing data from a database, and in particular, to a framework for re-writing database queries.
Unless otherwise indicated herein, the approaches described in this section are not prior art to the claims in this application and are not admitted to be prior art by inclusion in this section.
Databases have evolved to afford both increased capacity and complexity of the data that may be stored. In order to accommodate these features, customers can run complex queries on database tables from the application layer, without having to change the underlying data model.
Instead, databases such as in memory database architectures may rely upon complex models that join, project, and aggregate the existing tables using relational operators in order to provide insights to the user. The resulting database queries that are executed utilizing the models may implicate up to hundreds of database tables, and produce results comprising many individual records.
Typically however, an ordinary user is not an expert in either modeling or database structure/operation. Instead, the user formulates a query in a declarative way using structured query language (SQL). This SQL statement is then written to an execution plan that is understandable by the database.
Under certain circumstances, it may be desirable to re-write such a formal query prior to actual execution on the database. In a highly simplified example, a formal query may implicate data stored at tables A, B, and C of a database. Merging those tables in one sequence {A+B}+C to obtain a query result, however, may be significantly less efficient from a processing standpoint than merging the tables in a different sequence (such as A+{B+C}).